<?php
namespace app\serverarticle\validate;

use \app\manage\validate\BaseValidate;
/**
 * @Author: 蒋哲
 * @Date:   2017-05-25 11:49:42
 * @Last Modified by:   Marte
 * @Last Modified time: 2017-08-15 15:13:41
 */
class Article extends BaseValidate
{
    protected $rule = [
        'id'          => ['require'],
        'title'       => ['require', 'min'=>2, 'max'=>50],
        'classify_id' => ['require'],
        'author'      => ['require', 'min'=>2, 'max'=>10],
        'shortname'   => ['require', 'min'=>2, 'max'=>15],
        'keywords'    => ['require', 'min'=>2, 'max'=>30],
        'description' => ['require', 'min'=>2, 'max'=>30],
        'content'     => ['require'],
        'writer_id'   => ['require'],
        'nickname'    => ['chsAlphaNum'],
        'audit_id'    => ['require'],
        'visible'     => ['array', 'max'=>10],
        'invisible'   => ['array', 'max'=>10]
    ];

    protected $message = [
        'title.require'       => '文章标题不能为空！',
        'classify_id.require' => '文章分类id不能为空！',
        'content.require'     => '文章内容不能为空！',
        'writer_id.require'   => '作者id不能为空！',
        'author.require'      => '作者不能为空！',
        'author.min'          => '作者名不能短于两个字！',
        'author.max'          => '作者名不能长于十个字！',
        'shortname.max'       => '简略标题不能长于15个字！',
        'keywords.max'        => '关键字不能长于30个字！',
        'description.max'     => '描述不能长于30个字！'
    ];

    protected $scene = [
        'add'         => ['title', 'classify_id', 'author', 'content', 'nickname', 'shortname', 'keywords', 'description'],
        'edit'        => ['id', 'title', 'author', 'nickname', 'content', 'shortname', 'keywords', 'description'],
        'status'      => ['id'],
        'audit'       => ['id','audit_id'],
        'list'        => ['classify_id','page','listRows'],
        'visible'     => ['id', 'visible'],
        'invisible'   => ['id', 'invisible'],
        'articleList' => ['page', 'listRows'],
    ];
}